/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2008                    */
/* Created on:     25/05/2013 09:14:38 a.m.                     */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASOC_TBLINFRACCION')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASOC_TBLINFRACCION
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASSOCIATI_TBLSECRE')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASSOCIATI_TBLSECRE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASSOCIATI_TBLVEHIC')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASSOCIATI_TBLVEHIC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASOC_TBLINFRACTOR')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASOC_TBLINFRACTOR
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASSOCIATI_TBLAGENT')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASSOCIATI_TBLAGENT
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblComparendo') and o.name = 'FK_TBLCOMPA_ASSOCIATI_TBLDIREC')
alter table TblComparendo
   drop constraint FK_TBLCOMPA_ASSOCIATI_TBLDIREC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblInfraccion') and o.name = 'FK_TBLINFRA_ASSOCIATI_TBLARTIC')
alter table TblInfraccion
   drop constraint FK_TBLINFRA_ASSOCIATI_TBLARTIC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblInfractor') and o.name = 'FK_TBLINFRA_ASSOCIATI_TBLLICEN')
alter table TblInfractor
   drop constraint FK_TBLINFRA_ASSOCIATI_TBLLICEN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblInfractor') and o.name = 'FK_TBLINFRA_ASSOCIATI_TBLDIREC')
alter table TblInfractor
   drop constraint FK_TBLINFRA_ASSOCIATI_TBLDIREC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblLicenciaConduccion') and o.name = 'FK_TBLLICEN_ASSOCIATI_TBLSECRE')
alter table TblLicenciaConduccion
   drop constraint FK_TBLLICEN_ASSOCIATI_TBLSECRE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('TblSecretariaDeTransito') and o.name = 'FK_TBLSECRE_ASSOCIATI_TBLDIREC')
alter table TblSecretariaDeTransito
   drop constraint FK_TBLSECRE_ASSOCIATI_TBLDIREC
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblAgente')
            and   type = 'U')
   drop table TblAgente
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblArticulo')
            and   type = 'U')
   drop table TblArticulo
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('TblComparendo')
            and   name  = 'ASSOCIATION1_FK'
            and   indid > 0
            and   indid < 255)
   drop index TblComparendo.ASSOCIATION1_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblComparendo')
            and   type = 'U')
   drop table TblComparendo
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblDireccion')
            and   type = 'U')
   drop table TblDireccion
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('TblInfraccion')
            and   name  = 'ASSOCIATION8_FK'
            and   indid > 0
            and   indid < 255)
   drop index TblInfraccion.ASSOCIATION8_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblInfraccion')
            and   type = 'U')
   drop table TblInfraccion
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('TblInfractor')
            and   name  = 'ASSOCIATION5_FK'
            and   indid > 0
            and   indid < 255)
   drop index TblInfractor.ASSOCIATION5_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblInfractor')
            and   type = 'U')
   drop table TblInfractor
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('TblLicenciaConduccion')
            and   name  = 'ASSOCIATION11_FK'
            and   indid > 0
            and   indid < 255)
   drop index TblLicenciaConduccion.ASSOCIATION11_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblLicenciaConduccion')
            and   type = 'U')
   drop table TblLicenciaConduccion
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('TblSecretariaDeTransito')
            and   name  = 'ASSOCIATION9_FK'
            and   indid > 0
            and   indid < 255)
   drop index TblSecretariaDeTransito.ASSOCIATION9_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblSecretariaDeTransito')
            and   type = 'U')
   drop table TblSecretariaDeTransito
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TblVehiculo')
            and   type = 'U')
   drop table TblVehiculo
go

